@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #4a90e2;
    --success-color: #50e3c2;
    --warning-color: #f5a623;
    --danger-color: #d0021b;
    --light-gray-color: #f8f9fa;
    --medium-gray-color: #e9ecef;
    --dark-gray-color: #343a40;
    --text-color: #212529;
    --card-bg: #ffffff;
    --border-radius: 12px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

html {
    box-sizing: border-box;
    width: 100%;
    overflow-x: hidden;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f2f5;
    color: var(--text-color);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
}

.dashboard {
    max-width: 1300px;
    margin: 0 auto;
    width: 100%;
    overflow-x: hidden;
    padding: 15px;
    box-sizing: border-box;
}

header {
    margin-bottom: 40px;
    background-color: var(--primary-color);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    text-align: center;
    margin: 0;
}

h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 24px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 8px;
    display: inline-block;
}

.year-toggle {
    margin-bottom: 20px;
}

.toggle-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.toggle-btn:hover {
    background-color: #3a7bc8;
}

.toggle-btn:active {
    transform: translateY(1px);
}

section {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: var(--shadow);
}

.overview-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 16px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 8px;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.overview-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.overview-card {
    flex: 0 0 auto;
    width: 200px;
    min-width: 200px;
    background-color: #f8f9fa;
    padding: 16px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-left: 5px solid var(--primary-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-align: center;
}

.overview-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.overview-card h3 {
    margin-top: 0;
    font-size: 1.2rem;
    color: #6c757d;
    font-weight: 500;
}

.overview-card p {
    font-size: 3rem;
    font-weight: 700;
    margin: 12px 0 0;
}

#total-arrears-months { color: var(--danger-color); }
#yearly-settled-months { color: var(--success-color); }
#yearly-unpaid-months { color: var(--warning-color); }

.monthly-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    position: relative;
}

.monthly-breakdown {
    overflow-x: auto;
}

/* 固定月份列 */
.monthly-table th:first-child,
.monthly-table td:first-child {
    position: sticky;
    left: 0;
    background-color: var(--card-bg);
    z-index: 1;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.monthly-table th:first-child {
    background-color: var(--primary-color);
}

.monthly-table thead {
    background-color: var(--primary-color);
    color: white;
}

.monthly-table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
}

.monthly-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--medium-gray-color);
}

.monthly-table tr:last-child td {
    border-bottom: none;
}

.year-header {
    background-color: #e9ecef;
    font-weight: 700;
    text-align: center;
}

.year-header td {
    padding: 12px;
    font-size: 1.2rem;
}

.status-label {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-paid {
    background-color: rgba(80, 227, 194, 0.2);
    color: #0d8a6f;
}

.status-partial {
    background-color: rgba(245, 166, 35, 0.2);
    color: #b36a00;
}

.status-unpaid {
    background-color: rgba(208, 2, 27, 0.2);
    color: #a30113;
}

.status-future {
    background-color: rgba(108, 117, 125, 0.2);
    color: #495057;
}

.status-cash {
    background-color: rgba(155, 89, 182, 0.2);
    color: #8e44ad;
}

.chart-container {
    margin-bottom: 32px;
    background-color: white;
    padding: 16px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.chart-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--medium-gray-color);
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    color: var(--dark-gray-color);
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 移动端适配 */
@media (max-width: 768px) {
    body {
        padding: 0;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .dashboard {
        width: 100%;
        max-width: 100%;
        padding: 10px;
        margin: 0;
    }
    
    header {
        padding: 15px;
        margin-bottom: 15px;
        width: 100%;
        box-sizing: border-box;
        border-radius: 8px;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.4rem;
    }
    
    section {
        padding: 15px;
        margin-bottom: 20px;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .overview-container {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .overview-card {
        width: 100%;
        min-width: auto;
        box-sizing: border-box;
    }
    
    .overview-card p {
        font-size: 2rem;
    }
    
    .monthly-table {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        width: 100%;
        max-width: 100%;
        -webkit-overflow-scrolling: touch;
    }
    
    .monthly-table th,
    .monthly-table td {
        padding: 8px;
    }
    
    .status-label {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
    
    .chart-container {
        padding: 10px;
        margin-bottom: 20px;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .chart-tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .chart-note {
        font-size: 0.8rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    main {
        width: 100%;
        overflow: hidden;
    }
}

/* 小屏幕手机适配 */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .toggle-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .overview-card h3 {
        font-size: 1rem;
    }
    
    .overview-card p {
        font-size: 1.8rem;
    }
}

.monthly-table th, .monthly-table td {
    padding: 20px 24px;
    text-align: left;
    border-bottom: 1px solid var(--medium-gray-color);
}

.monthly-table thead {
    background-color: var(--primary-color);
    color: white;
}

.monthly-table th {
    font-weight: 600;
    font-size: 1rem;
}

.monthly-table tbody tr:last-child td {
    border-bottom: none;
}

.monthly-table tbody tr:hover {
    background-color: #f1f3f5;
}

.status-label {
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-label::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-paid {
    background-color: var(--success-color);
}
.status-paid::before { background-color: white; }

.status-partial {
    background-color: var(--warning-color);
}
.status-partial::before { background-color: white; }

.status-unpaid {
    background-color: var(--danger-color);
}
.status-unpaid::before { background-color: white; }

.status-future {
    background-color: #909db7;
}
.status-future::before { background-color: white; }
